package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description: 链表尾插法
 * User: liangyuanzhang
 * Date: 2025-3-17
 * Time: 22:18
 */
public class Test {
    public void addList(int data){
        ListNode node = new ListNode(data);
        if (head == null){
            head = node;
            return;
        }
        ListNode cur = head;
        while (cur.next != null){
            cur = cur.next;  // 找到尾巴
        }
        cur.next = node;
    }
}
